package p.jce;

import java.security.AlgorithmParameters;
import java.security.AlgorithmParametersSpi;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Provider;

public class RAlgorithmParameters {
	private static class X extends AlgorithmParameters {

		protected X(AlgorithmParametersSpi paramSpi, Provider provider, String algorithm) {
			super(paramSpi, provider, algorithm);
		}
	}

	public static AlgorithmParameters getInstance(String algorithm, Provider provider) throws NoSuchAlgorithmException {
		return getInstance(algorithm);
	}

	public static AlgorithmParameters getInstance(String algorithm, String provider) throws NoSuchAlgorithmException,
			NoSuchProviderException {
		if ("BC".equals(provider)) {
			try {
				return new X((AlgorithmParametersSpi) BC.newInstance("AlgorithmParameters", algorithm), null, algorithm);
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return AlgorithmParameters.getInstance(algorithm, provider);
	}

	public static AlgorithmParameters getInstance(String algorithm) throws NoSuchAlgorithmException {
		try {
			return getInstance(algorithm, "BC");
		} catch (NoSuchProviderException e) {
			throw new RuntimeException(e);
		}
	}
}
